<?php
namespace App\Http\Controllers\H5;

use App\Service\H5\IndexService;
use Illuminate\Http\Request;

class IndexController extends BaseController
{
    //首页列表
    public function index(Request $request)
    {
        $pas['role_id'] = $request->post('role_id', 0);
        $pas['depart_id'] = $request->post('depart_id', 0);
        $res = IndexService::index($pas);
        if ($res['code'] < 0) {
            return self::toJson(-2, $res['msg']);
        }
        return self::toJson(0, '', $res['data']);
    }

    //审核拒绝
    public function authNo(Request $request)
    {
        $id = $request->post('id', 0);
        $uid = $request->post('uid', 0);
        $remark = $request->post('remark', '');
        $res = IndexService::authNo($id, $uid, $remark);
        if ($res['code'] < 0) {
            return self::toJson(-2, $res['msg']);
        }
        return self::toJson();
    }

    //审核同意
    public function authOk(Request $request)
    {
        $id = $request->post('id', 0);
        $uid = $request->post('uid', 0);
        $res = IndexService::authOk($id, $uid);
        if ($res['code'] < 0) {
            return self::toJson(-2, $res['msg']);
        }
        return self::toJson();
    }

    //重新修改
    public function authModify(Request $request)
    {
        $id = $request->post('id', 0);
        $uid = $request->post('uid', 0);
        $remark = $request->post('remark', '');
        $res = IndexService::authModify($id, $uid, $remark);
        if ($res['code'] < 0) {
            return self::toJson(-2, $res['msg']);
        }
        return self::toJson();
    }

    //回复
    public function authReply(Request $request)
    {
        $id = $request->post('id', 0);
        $uid = $request->post('uid', 0);
        $remark = $request->post('remark', '');
        $res = IndexService::authReply($id, $uid, $remark);
        if ($res['code'] < 0) {
            return self::toJson(-2, $res['msg']);
        }
        return self::toJson();
    }
}